import rand from './rand.js';
function mutate(rnvec, matrix) {
  const len = matrix.length;
  for (let i = 0; i < len; i++) {
    if (Math.random() < 0.2) {
      let linkNodes = [];
      for (let j = 0; j < len; j++) {
        if (matrix[i][j] === 1 && i !== j) {
          linkNodes.push(j);
        }
      }
      if (linkNodes.length === 0) continue;
      rnvec[i] = rnvec[linkNodes[rand(0, linkNodes.length - 1)]];
    }
  }
}
export default mutate;
